import requests
import re

url = 'https://news.4399.com/luoke/luokechongwu/'
response = requests.get(url)
html = response.content.decode('gbk')
print(html)
results = re.findall(
    r'.*?<li rel=".*?" name="(.*?)".*?>.*?<a href="(.*?.html)"><img class="pet-img fix-span" alt=".*?".*?lz_src="(.*?)">.*?</a>.*?<a class="pet-.*?" href=".*?".*?>.*?</a>.*?</li>',
    html, re.S)
for result in results:
    name = result[0]
    detail_url = 'https://news.4399.com' + result[1]
    img_url = 'https:' + result[2]
    img_response = requests.get(img_url)
    with open(f'../static/洛克王国/img/{name}.gif', 'wb') as f:
        f.write(img_response.content)
